import CryptoJS from "crypto-js";

/**
 * aes加解密
 */
export default {
    /**
     * aes加密
     * @param word
     * @returns {string}
     */
    encrypt(word) {
        let key = CryptoJS.enc.Utf8.parse("wdxxgfyxgsQHSJJH");
        let srcs = CryptoJS.enc.Utf8.parse(word);
        let encrypted = CryptoJS.AES.encrypt(srcs, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7});
        return encrypted.toString();
    },

    /**
     * aes解密
     * @param word
     * @returns {*}
     */
    decrypt(word) {
        let key = CryptoJS.enc.Utf8.parse("wdxxgfyxgsQHSJJH");
        let decrypt = CryptoJS.AES.decrypt(word, key, {mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7});
        return CryptoJS.enc.Utf8.stringify(decrypt).toString();
    }
}